#!/bin/bash
#查看本机是否有密钥对

    if [ -f ~/.ssh/id_rsa ];then
         rm -rf  ~/.ssh/id_rsa*
    fi
#生成密钥对
ssh-keygen -t rsa -f ~/.ssh/id_rsa -P "" &> /dev/null
#保证目标主机的环境的一致
> ~/.ssh/known_hosts

for i in 131 132; do
    /usr/bin/expect << aaa
    set timeout 10
    spawn ssh-copy-id root@192.168.88.$i
    expect "(yes/no)?"
    send "yes\n"
    expect "password"
    send "////\n"
    expect eof
aaa
done

echo "验证是否配置免密"
echo “————”
ssh root@192.168.88.131 date
